<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
    import Edit from "./../edit/index";
    export default {
        mixins: [Vue.prototype.$vFN.Mixins.Base, Vue.prototype.$vFN.Mixins.Page, Vue.prototype.$vFN.Mixins.Table],
        components: {
        },
        data() {
            return {
                // 页面接口地址
                apiUrl: {
                    list: "mall-site-portal/platform/list",
                    delete: "",
                },
                // 表格查询数据
                mixinTable_tableSearchData: {
                    name: "",
                    expireStatus: 0,
                    closeStatus: 0,
                    status: 0,
                },
                // 表格数据
                tableData: [],
                // 表格数据删除展示结构
                tableDeleteConfig: {
                    columns: [{
                            label: "站点名称",
                            prop: "name",
                            type: ""
                        },
                        {
                            label: "管理员",
                            prop: "mobile",
                            type: ""
                        },
                        {
                            label: "过期类型",
                            prop: "mobile",
                            type: "expireStatusMap.dictLabel"
                        },
                        {
                            label: "运行状态",
                            prop: "statusMap.dictLabel",
                            type: ""
                        },
                    ],
                },

              
                // 到期状态
                dict_platform_expire: [],

            };
        },
        methods: {
            toSite(id_){
                let _token = localStorage.getItem("adminToken");
                if(_token){
                    localStorage.setItem("siteToken", _token)
                    window.open("/site/manage/dashboard?sid="+id_);
                }
            },
            // 打开添加/修改
            editBoxOpen(params_) {
                 Edit.init({
                    mixinEdit_parent:this,
                    mixinEdit_editType: params_.type,
                    id: params_.id,
                })
            },
            // 初始化
            async init() {
                this.mixinTable_initSearchData();
            },

            // 开启
            async submitPlatformStatus(data_, type_) {
                let _data = await this.$vFN.Http.post({
                    url: "mall-site-portal/platform/" + type_,
                    data: {
                        id: data_.id,
                    },
                });
                if (_data._ok) {
                    // 刷新页面
                    this.mixinTable_refreshData();
                }
            },
            // 关闭
            confirmPlatformStatus(data_, type_) {
                let _t = "关闭";
                if (type_ == 'enable') {
                    _t = "开启"
                }
                this.$confirm("此操作将  <strong>" + _t + "</strong>  此站点, 是否继续?", "【" + data_.name + "】站点" + _t + "提示", {
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        // type: "error",
                        dangerouslyUseHTMLString: true,
                    }).then(() => {
                        this.submitPlatformStatus(data_, type_)
                    })
                    .catch(() => {});

            },

        },
        mounted() {
            this.init();

        },
        activated() {},
    };
</script>